package pers.qianyu.month_202103.date_20210328;

import pers.qianyu.util.model.ListNode;

/**
 * 83. 删除排序链表中的重复元素
 * https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/
 *
 * @author mizzle rain
 * @date 2021-03-28 14:29
 */
public class DeleteDuplicates {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null) return head;
        for (ListNode cur = head, next = null; cur != null; cur = cur.next) {
            int v = cur.val;
            next = cur.next;
            while (next != null && next.val == v) next = next.next;
            cur.next = next;
        }
        return head;
    }
}
